cmake_minimum_required(VERSION 3.21)
project(untitled)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fexec-charset=GBK")
set(CMAKE_CXX_STANDARD 20)

set(JUST_INSTALL_CEREAL 1)

add_subdirectory(cereal)
add_subdirectory(glm)
add_subdirectory(D3D12RHI)
add_subdirectory(USRefl)

## Component元信息
file(GLOB Components ${CMAKE_CURRENT_LIST_DIR}/Scene/Component/*.h)
FOREACH(FILE_PATH ${Components})
    CMAKE_PATH(GET FILE_PATH STEM fullstem)
    string(APPEND fullStemSet ${fullstem},)
    string(APPEND INCLUDE_COMPONENTSET "#include\"${FILE_PATH}\" " " \n")

    Ubpa_USReflAutoRefl(
            "${FILE_PATH}"
            "${FILE_PATH}.inl"
    )
    list(APPEND AUTOReflGen "${FILE_PATH}.inl")
ENDFOREACH()
string(FIND ${fullStemSet} , id REVERSE)
string(SUBSTRING  ${fullStemSet} 0 ${id} fullStemSet)
configure_file(${CMAKE_CURRENT_LIST_DIR}/Scene/ComponentConfig.h.in ${CMAKE_CURRENT_LIST_DIR}/Scene/Components.h)


add_executable(untitled main.cpp ${AUTOReflGen} Scene/Scene.cpp RenderEngine.cpp RenderEngine.h D3D12RHI/RenderPipeline.cpp D3D12RHI/RenderPipeline.h Editor.cpp Editor.h Scene/Component/Camera.cpp Scene/Component/Camera.h Scene/Component/Mesh.cpp Scene/Component/Mesh.h Scene/Component/Vec.h Scene/Component/Material.h )

message("PROJECT_BINARY_DIR=${PROJECT_BINARY_DIR}")


target_include_directories(untitled PUBLIC "${PROJECT_BINARY_DIR}")

target_include_directories(untitled PRIVATE entt/single_include)

target_link_libraries(untitled D3D12RHI cereal Ubpa::USRefl_core glm::glm)